﻿@model KPIS.GERP.Models.ICM.MasContactBank
 
@{
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    ViewBag.Title = "เพิ่มข้อมูล สมุดเงินฝากธนาคารของผู้ขาย";
    ViewBag.Descr = "เพิ่มข้อมูล สมุดเงินฝากธนาคารของผู้ขาย";
}

@using (Html.BeginForm("CreateBank", "MasContact", FormMethod.Post, new { id="form1", @class = "form-horizontal" }))
{
    @Html.AntiForgeryToken()

    <div class="block-button-menu-above">
        @Html.ActionLink("กลับไปหน้าแสดงข้อมูลทั้งหมด", "IndexBank", new { ConId = Model.ConId }, new { @class = "btn btn-gray button-standard-width btn-small", role="button" })
        @Html.ButtonSubmit()
    </div>
    
    <div class="alert-error">@Html.ValidationSummary()</div>
    
    @Html.Partial("_EditorFormBank")

}

@section scripts
{
    <script>
        $(function () {
            $("#form1").submit(function (e) {
                e.preventDefault();
                var currentForm = this;
                bootbox.confirm(function (result) {
                    if (result) {
                        currentForm.submit();
                    }
                });
            });

            $(".chzn-select").chosen({ width: '220px' });

            $("#ddlBank").change(function () {
                var id = $('#ddlBank').val();

                if (id != '') {
                    $.getJSON('@Url.Action("GetBankBranchList")?BankId=' + id, function (data) {
                        $('#ddlBankBranch').empty();
                        var items = '';
                        $.each(data, function (i, result) {
                            $('#ddlBankBranch').append("<option value='" + result.Value + "'>" + result.Text + "</option>");
                        });
                        $("#ddlBankBranch").trigger("liszt:updated");//update list
                    });
                }
                else {
                    $('#ddlBankBranch').empty();
                }
            });
        });
    </script>
}